package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.entity.SysAdminUser;
import com.ruoyi.common.core.domain.entity.SysUserVO;
import com.ruoyi.common.core.page.PageUtil;
import com.ruoyi.system.domain.dto.SysAdminUserDTO;
import com.ruoyi.system.mapper.SysAdminUserMapper;
import com.ruoyi.system.service.ISysAdminProjectService;
import com.ruoyi.system.service.ISysAdminUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wux
 * @date 2023/5/11 10:03
 */
@Service
public class SysAdminUserServiceImpl extends ServiceImpl<SysAdminUserMapper, SysAdminUser> implements ISysAdminUserService {
    @Autowired
    private ISysAdminProjectService adminProjectService;
    @Override
    public List<SysUserVO> listByPage(SysAdminUserDTO.AdminUserSelectDTO params) {
        PageUtil.startPage(params);
        List<SysUserVO> userList = this.baseMapper.listByPage(params);
        userList.forEach(item -> {
            //查询用户项目
            item.setProjectList(adminProjectService.getProjectByUser(item.getId()));
        });
        return userList;
    }
}
